﻿using System;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;

namespace WEIShareWCFRole.BusinessEntities
{
    /// <summary>
    /// Summary description for WindowsAccess
    /// </summary>
    [DataContract]
    public class WindowsAssessment
    {
        public Guid? WindowsAssessmentID { get; set; }
        [DataMember]
        public decimal? SystemScore { get; set; }
        [DataMember]
        public decimal? AverageScore { get; set; }
        [DataMember]
        public decimal? MemoryScore { get; set; }
        [DataMember]
        public decimal? CpuScore { get; set; }
        [DataMember]
        public decimal? CpuSubAggScore { get; set; }
        [DataMember]
        public decimal? VideoEncodeScore { get; set; }
        [DataMember]
        public decimal? GraphicsScore { get; set; }
        [DataMember]
        public decimal? GamingScore { get; set; }
        [DataMember]
        public decimal? DiskScore { get; set; }
        [DataMember]
        public string SystemManufacturer { get; set; }
        [DataMember]
        public string SystemModel { get; set; }
        [DataMember]
        public string SystemType { get; set; }
        [DataMember]
        public string OSVersionBuild { get; set; }
        [DataMember]
        public string OSVersionProductType { get; set; }
        [DataMember]
        public string OSVersionProductName { get; set; }
        [DataMember]
        public bool? PlatformIsMobile { get; set; }
        [DataMember]
        public string PlatformRole { get; set; }
        [DataMember]
        public string PlatformRoleDesc { get; set; }
        [DataMember]
        public string ProcessorName { get; set; }
        [DataMember]
        public long? ProcessorFrequency { get; set; }
        [DataMember]
        public int? ProcessorNumProcs { get; set; }
        [DataMember]
        public int? ProcessorNumCores { get; set; }
        [DataMember]
        public int? ProcessorNumCPUs { get; set; }
        [DataMember]
        public int? ProcessorNumCPUsPerCore { get; set; }
        [DataMember]
        public int? ProcessorNumCoresPerProcessor { get; set; }
        [DataMember]
        public bool? ProcessorX64Capable { get; set; }
        [DataMember]
        public bool? ProcessorX64Running { get; set; }
        [DataMember]
        public int? ProcessorL1CacheSize { get; set; }
        [DataMember]
        public int? ProcessorL2CacheSize { get; set; }
        [DataMember]
        public string MACAddress { get; set; }
        [DataMember]
        public string MemoryPhysicalSize { get; set; }
        [DataMember]
        public long? MemoryPhysicalSizeBytes { get; set; }
        [DataMember]
        public string MemoryAvailablePhysicalSize { get; set; }
        [DataMember]
        public long? MemoryAvailablePhysicalSizeBytes { get; set; }
        [DataMember]
        public string MemoryType { get; set; }
        [DataMember]
        public int? MemoryTypeID { get; set; }
        [DataMember]
        public int? MemorySpeed { get; set; }
        [DataMember]
        public int? MonitorsCount { get; set; }
        [DataMember]
        public int? MonitorWidth { get; set; }
        [DataMember]
        public int? MonitorHeight { get; set; }
        [DataMember]
        public int? MonitorTotalPixels { get; set; }
        [DataMember]
        public string GraphicsAdapterDescription { get; set; }
        [DataMember]
        public string GraphicsAdapterManufacturer { get; set; }
        [DataMember]
        public long? GraphicsDedicatedVideoMemory { get; set; }
        [DataMember]
        public long? GraphicsDedicatedSystemMemory { get; set; }
        [DataMember]
        public long? GraphicsSharedSystemMemory { get; set; }
        [DataMember]
        public bool? GraphicsSupports32BitsPerPixel { get; set; }
        [DataMember]
        public string GraphicsDriverVersion { get; set; }
        [DataMember]
        public string GraphicsDirectXVersion { get; set; }
        [DataMember]
        public long? DiskSize { get; set; }
        [DataMember]
        public long? DiskSizeAvailable { get; set; }
        [DataMember]
        public decimal? DiskSpeed { get; set; }
        [DataMember]
        public int? TouchPointCount { get; set; }
        [DataMember]
        public string OverallColumnText { get { return (SystemManufacturer != null ? Regex.Replace(SystemManufacturer.Trim(), "[ ]+", evaluator => " ") + " " : "") + (SystemModel != null ? Regex.Replace(SystemModel.Trim(), "[ ]+", evaluator => " ") + " with " : "") + (OSVersionProductName != null ? Regex.Replace(OSVersionProductName.Trim(), "[ ]+", evaluator => " ") + " " : "") + (ProcessorX64Capable.GetValueOrDefault(false) ? "(64-bit)" : ""); } set { } }
        [DataMember]
        public string ProcessorColumnText { get { return (ProcessorName != null ? Regex.Replace(ProcessorName.Trim(), "[ ]+", evaluator => " ") : ""); } set { } }
        [DataMember]
        public string MemoryColumnText { get { return (MemoryPhysicalSize != null ? MemoryPhysicalSize.Trim() + " " : "") + (MemoryType != null && MemoryTypeID.GetValueOrDefault(0) != 0 && MemoryTypeID.GetValueOrDefault(0) != 1 ? MemoryType.Trim() + " " : "") + MemorySpeed; } set { } }
        [DataMember]
        public string GraphicsColumnText { get { return Regex.Replace(GraphicsAdapterDescription.Trim(), "[ ]+", evaluator => " ") + (string.IsNullOrEmpty(GraphicsDriverVersion) ? "" : " (" + GraphicsDriverVersion + ")" + " "); } set { } }
        [DataMember]
        public string TouchPointColumnText
        {
            get
            {
                int pointCount = TouchPointCount.GetValueOrDefault(0);
                return pointCount + (pointCount == 1 ? " Point" : " Points"); 
            }
            set { }
        }
        [DataMember]
        public string GamingGraphicsColumnText
        {
            get
            {
                long bytes = (GraphicsDedicatedSystemMemory.GetValueOrDefault(0) + GraphicsDedicatedVideoMemory.GetValueOrDefault(0) + GraphicsSharedSystemMemory.GetValueOrDefault(0));
                decimal gigaBytes = Convert.ToDecimal(bytes) / 1073741824;
                decimal megaBytes = gigaBytes * 1024;
                string returnText = Math.Round(gigaBytes, 0) + "GB";

                if (gigaBytes < 1)
                    returnText = Math.Round(megaBytes, 0) + "MB";


                return returnText;
            }
            set { }
        }
        [DataMember]
        public string PrimaryHardDiskColumnText
        {
            get
            {
                long bytes = DiskSize.GetValueOrDefault(0);
                long availableBytes = DiskSizeAvailable.GetValueOrDefault(0);
                decimal gigaBytes = Convert.ToDecimal(bytes) / 1073741824;
                decimal gigaBytesAvailable = Convert.ToDecimal(availableBytes) / 1073741824;

                string returnText = Math.Round(gigaBytes, 0) + "GB (" + Math.Round(gigaBytesAvailable, 0) + "GB free)";

                return returnText;
            }
            set { }
        }
    }
}